const path = require("path");

function resolve(dir) {
    return path.join(__dirname, dir);
}

module.exports = {
    publicPath: process.env.BASE_URL,
    lintOnSave: true,
    productionSourceMap: false,
    chainWebpack: (config) => {
        config.resolve.alias.set("@", resolve("src"));

        //修改htmlWebpackPlugin
        config.plugin("html").tap((args) => {
            args[0].title = process.env.VUE_APP_TITLE;
            return args;
        });
    },
    configureWebpack: (config) => {
        config.externals = {
            vue: "Vue",
            "vue-router": "VueRouter",
            vuex: "Vuex",
            axios: "axios",
            echarts: "echarts",
            element: "Element"
        };
        config.performance = {
            maxEntrypointSize: 1024 * 1024,
            maxAssetSize: 1024 * 1024,
            assetFilter: function (assetFilename) {
                return assetFilename.endsWith(".js");
            }
        };
    }
};
